package com.casework

class AttachedFile{
    String path
    String contentType
    boolean internalFileOnly = false
    LegalCase legalCase

    static belongsTo = [legalCase:LegalCase]

    static constraints = {
        path nullable: false, unique: true
        contentType nullable: true
    }

    String toString(){
        def names = path.split('/');
        return names.last()
    }

    void beforeDelete() {
        File file = new File(path)
        file.delete()
    }
}